define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_RestWPSSService', function (sourceId, url, http, authType, clientId, clientSecret, tokenUrl) {
        try {
            //var restHttp = Window.container[http];
            var restGeoService = new egis.ews.RestWPSSService({
                url: url,
                //http: restHttp,
                deserializer: Window.deserializer,
                authType: authType,
                clientId: clientId,
                clientSecret: clientSecret,
                tokenUrl: tokenUrl
            });
            Window.container[sourceId] = restGeoService;
        }
        catch (e) {
            alert(e);
        }

    })

    dsBridge.registerAsyn('RestWPSSService_searchKeyWord', function (sourceId, searchKeywordInput, responseCallback) {
        var restWPSSService = Window.container[sourceId];
        searchKeywordInput = Window.deserializer.createJsInstance(JSON.parse(searchKeywordInput));
        restWPSSService.searchKeyWord(searchKeywordInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWPSSService_searchAround', function (sourceId, searchAroundInput, responseCallback) {
        var restWPSSService = Window.container[sourceId];
        searchAroundInput = Window.deserializer.createJsInstance(JSON.parse(searchAroundInput));
        restWPSSService.searchAround(searchAroundInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })

    })

    dsBridge.registerAsyn('RestWPSSService_searchBounds', function (sourceId, searchBoundsInput, responseCallback) {
        var restWPSSService = Window.container[sourceId];
        searchBoundsInput = Window.deserializer.createJsInstance(JSON.parse(searchBoundsInput));
        restWPSSService.searchBounds(searchBoundsInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWPSSService_searchDetail', function (sourceId, searchDetailInput, responseCallback) {
        var restWPSSService = Window.container[sourceId];
        searchDetailInput = Window.deserializer.createJsInstance(JSON.parse(searchDetailInput));
        restWPSSService.searchDetail(searchDetailInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })
})